﻿var path = "http://" + location.host + "/SSTA/achieve/agent/";

var kjcgPath = "http://" + location.host + "/SSTA/achieve/";

var total=0;
var standard = "1";
var searchkeyword = "";
var str_pdtResults = "";


function replace_a(str,a,b){
	while(str.indexOf(a)!=-1){
			str=str.replace(a,b);
	}
	return str;
}
 
function showKjcgResult(data) {
		pagecap=5;
		var str = "";
		var str2 = "";
		var str3 = "";

	   var searchresult = "";
	   searchresult = "";
	   //新版页面html
	   var data = eval("("+data+")");
	   var total=0;
	   for(i =0;i<data.length;i++) {
	   		
	   		kjcgid = data[i]['kjcgid'];
	   		title = data[i]['kjcg_item_3'];
	   		unitid = data[i]['unitid'];
	   		unitname = data[i]['kjcg_item_9'];
	   		
	   		searchresult+="<div id='searchlist_left_kjcg'>";
	   		searchresult+="<ul><li style='width:100%;'><span>成果标题：</span>";
	   		//searchresult+=title;
	   		
	   		
	   		//searchresult+="<a href='"+expertPath+"info.jsp?expid=" + expertid + "&title="+expertname +"' target=\"_blank\">";
	   		
   			searchresult += "<a  style=\"color:#0F49A8;\" href='/SSTA/achieve/info.jsp?kjcgid=";
   			
   			
   			
   			
   			
            searchresult += kjcgid;
            searchresult += "&unitid=" + unitid;
            searchresult += "&title=" + title;  
            searchresult +=  "' target=\"_blank\">";
            searchresult += title;
            searchresult += "</a>";
	   		
	   		searchresult+="</li>";
	   		searchresult+="<li><span>完成单位：</span>";
	   		searchresult+=unitname;
	   		searchresult+="</li></ul>";
	   		
	   		searchresult+="<div id='morebotton_kjcg'>";
	   		
	   		searchresult += "<a  style=\"color:#0F49A8;\" href = '/SSTA/achieve/info.jsp?kjcgid=";
            searchresult += kjcgid;
            searchresult += "&unitid=" + unitid;
            searchresult += "&title=" + title;  
            searchresult +=  "' target=\"_blank\">";
            searchresult += "<img src='../common/images/search/botton4.gif' border='0' />";
            searchresult += "</a>";
	   		
	   		
	   		searchresult+="</div></div><div id='clearboth'></div>";
	   		
	   		total = data[i]['total'];
	   }
       
       totalpage = Math.ceil(total / pagecap);
       
       str2+="<div style=\"height:20px;\"></div>";
	   str2 += "<div  style=\"margin-right:5px;cursor:hand;\" id = 'mylink'>" + setPage(cCount);    
	   str2 += "</div>";
	   
	  // alert(str2);
	   
       str3 = "<div style=\"margin-right:5px;margin-top:-10px;cursor:hand;\" id = 'mylink1'>" + "总页数："+ totalpage +"　"+setPage(cCount);    
	   str3 += "</div>";
	   
	   
	   if(document.getElementById("kjcg_res")!=null){
	   	     document.getElementById("progressbar").style.display='none';
	   		 document.getElementById("kjcg_res").innerHTML = searchresult + "<div style=\"margin-top:20px;\">"+ str2+"</div>" ; 
	   }
	   
	  
	  if (document.getElementById("blue_title") !=null){
             if (topicname != ""){
				document.getElementById("blue_title").innerHTML = "<div>您的搜索条件：<font color=\"#0F49A8\">"+topicname+"</font>　　我们为您找到：<font color=\"#0F49A8\">"+total+"</font> 条项目</div>";
             }else{
                document.getElementById("blue_title").innerHTML = "<div>共搜索到：<font color=\"#0F49A8\">" + total + "</font>条项目</div>";
      		 }                  
	  }
}





function showKjcgInfo(data) {

	var str = "";
    var str1="";
    
    var data = eval("("+data+")");
    
	if(data != null) {
	    var j = 0;
        
        if(data.length == 0) {
			return;
	    }
	    
	    
	    title = data['kjcg_item_3'];
	    
	    
	    
	    //设置info页面显示标题
	    document.getElementById("int_show_con_title").innerHTML = title;
	    //设置info页面收藏from中infotitle输入框的value
	    document.getElementById("infotitle").value = title;
	    
	    
	    
        str += "<div class=\"blank10\"></div>";
	    str += "<table class=\"table_info\" cellspacing=\"0\"  align=\"center\">";
            
        if (null != data['kjcg_item_9'] && data['kjcg_item_9'] != "null"&& data['kjcg_item_9'] != ""){
	        str += "<tr><td width=\"20%\">【完成单位】　</td><td>";
                str += data['kjcg_item_9'];	
                str += "</td></tr>";		
	    }

            if (null != data['kjcg_item_cglb'] && data['kjcg_item_cglb'] != "null"&& data['kjcg_item_cglb'] != ""){
	       str += "<tr><td >【成果类别】　</td><td>";
	       str += data['kjcg_item_cglb']+"&nbsp;";
               str += "</td></tr>";
            }

            if (enjoytype == "2") {	
            
            if (null != data['kjcg_item_120'] && data['kjcg_item_120'] != "null"&& data['kjcg_item_120'] != ""){
	       str += "<tr><td>【成果登记号】　</td><td>";
	       str += data['kjcg_item_120']+"&nbsp;";
	       str += "</td></tr>";
	    }

            if (null != data['kjcg_item_121'] && data['kjcg_item_121'] != "null"&& data['kjcg_item_121'] != ""){
	       str += "<tr><td>【成果登记时间】　</td><td>";
	       str += data['kjcg_item_121']+"&nbsp;";	
	       str += "</td></tr>";
	    }

            }
            
            if (null != data['kjcg_item_8'] && data['kjcg_item_8'] != "null"&& data['kjcg_item_8'] != ""){
	     str += "<tr><td>【研究起止时间】　</td><td>";
	     str += data['kjcg_item_8']+"&nbsp;";	
	     str += "</td></tr>";
	    }

           
            if (null != data['kjcg_item_123'] && data['kjcg_item_123'] != "null"&& data['kjcg_item_123'] != ""){
                   str += "<tr><td>【成果体现形式】　</td><td>";
	           str += data['kjcg_item_123']+"&nbsp;";	
	           str += "</td></tr>";
            }
            
            if (null != data['kjcg_item_210'] && data['kjcg_item_210'] != "null"&& data['kjcg_item_210'] != ""){
                   str += "<tr><td>【成果体现形式】　</td><td>";
	           str += data['kjcg_item_210']+"&nbsp;";	
	           str += "</td></tr>";
            }
            
             if (null != data['kjcg_item_16'] && data['kjcg_item_16'] != "null"&& data['kjcg_item_16'] != ""){
             str += "<tr><td>【成果所处阶段】　</td><td>";
	     str += data['kjcg_item_16']+"&nbsp;";		
	     str += "</td></tr>";
	  }
        
          if (null != data['kjcg_item_125_1'] && data['kjcg_item_125_1'] != "null"&& data['kjcg_item_125_1'] != ""){
	     str += "<tr><td >【成果属性】　</td><td>";
	     str += data['kjcg_item_125_1']+"&nbsp;";	
	     str += "</td></tr>";
	  }

          if (null != data['kjcg_item_2'] && data['kjcg_item_2'] != "null"&& data['kjcg_item_2'] != ""){
	    str += "<tr><td>【成果水平】　</td><td>";
	    str += data['kjcg_item_2']+"&nbsp;";	
	    str += "</td></tr>";
	  }

          if (null != data['kjcg_item_201'] && data['kjcg_item_201'] != "null"&& data['kjcg_item_201'] != ""){
	    str += "<tr><td>【研究形式】　</td><td>";
	    str += data['kjcg_item_201']+"&nbsp;";
	    str += "</td></tr>";
	  }

       	  if (enjoytype == "2") {		               
          
          if (null != data['kjcg_item_41'] && data['kjcg_item_41'] != "null"&& data['kjcg_item_41'] != ""){
            str += "<tr><td>【联系人】　</td><td>";
	    str += data['kjcg_item_41']+"&nbsp;";
	    str += "</td></tr>";
          }
	
         if (null != data['kjcg_item_41_2'] && data['kjcg_item_41_2'] != "null"&& data['kjcg_item_41_2'] != ""){
	    str += "<tr><td>【联系人电话】　</td><td>";
	    str += data['kjcg_item_41_2']+"&nbsp;";
	    str += "</td></tr>";
	 }
        
         }  
         if (null != data['kjcg_item_13'] && data['kjcg_item_13'] != "null"&& data['kjcg_item_13'] != ""){
               str += "<tr><td colspan=\"2\">【简要技术说明】</td><tr>";
	       str += "<tr><td colspan=\"2\">　　";
	       var strabstract = data['kjcg_item_13'];
           
           //reg = new RegExp("(<br/>)","g");
 	       //strabstract = strabstract.replace(reg,'\r\n');
 	       
 	       strabstract = replace_a(strabstract,"<br/>","\r\n");
 	       
 	       strabstract = replace_a(strabstract,"-n-n-n","");
 	       
 	       
	       str += strabstract;	
	       str += "&nbsp;</td></tr>";
            }

            str += "</table>";
            
            if (document.getElementById("showkjcginfo") !=null){
                 document.getElementById("progressbar").style.display='none';  
		 		 document.getElementById("showkjcginfo").innerHTML = str;
	    }	
	    
	    
	   
         /*单位信息
        if ((nodelist.item(1) != null)&&(enjoytype == "2")){
              var node1=nodelist.item(1);
              str1="<div class=\"title_level2\">　完成单位</div>";
	      str1 += "<table class=\"table_info\" cellspacing=\"0\"  align=\"center\">";
           
              if (null != node1.selectSingleNode("./Item_9") && node1.selectSingleNode("./Item_9").text != "null"&& node1.selectSingleNode("./Item_9").text != ""){
	          str1 += "<tr><td width=\"20%\">【完成单位】　</td><td>";
                  str1 += node1.selectSingleNode("./Item_9").text;	
                  str1 += "</td></tr>";		
	      }

              if (null != node1.selectSingleNode("./Item_37") && node1.selectSingleNode("./Item_37").text != "null"&& node1.selectSingleNode("./Item_37").text != ""){
   	          str1 += "<tr><td>【单位通讯地址】　</td><td>";
	          str1 += node1.selectSingleNode("./Item_37").text+"&nbsp;";
                  str1 += "</td></tr>";
              }
  
              if (null != node1.selectSingleNode("./Item_38") && node1.selectSingleNode("./Item_38").text != "null"&& node1.selectSingleNode("./Item_38").text != ""){
	          str1 += "<tr><td>【邮政编码】　</td><td>";
	          str1 += node1.selectSingleNode("./Item_38").text+"&nbsp;";
                  str1 += "</td></tr>";
              }

              if (null != node1.selectSingleNode("./Item_39") && node1.selectSingleNode("./Item_39").text != "null"&& node1.selectSingleNode("./Item_39").text != ""){
	          str1 += "<tr><td>【单位电话】　</td><td>";
	          str1 += node1.selectSingleNode("./Item_39").text+"&nbsp;";	
	          str1 += "</td></tr>";
	      }

              if (null != node1.selectSingleNode("./Item_40") && node1.selectSingleNode("./Item_40").text != "null"&& node1.selectSingleNode("./Item_40").text != ""){
     	          str1 += "<tr><td >【单位传真】　</td><td>";
	          str1 += node1.selectSingleNode("./Item_40").text+"&nbsp;";	
	          str1 += "</td></tr>";
	      }

              if (null != node.selectSingleNode("./Item_60") && node.selectSingleNode("./Item_60").text != "null"&& node.selectSingleNode("./Item_60").text != ""){
                   str1 += "<tr><td>【单位网址】　</td><td>";
 	           str1 += node.selectSingleNode("./Item_60").text+"&nbsp;";	
	           str1 += "</td></tr>";
              }
            
              if (enjoytype == "2") {
              if (null != node1.selectSingleNode("./LinkMan") && node1.selectSingleNode("./LinkMan").text != "null"&& node1.selectSingleNode("././LinkMan").text != ""){
                   str1 += "<tr><td>【联系人】　</td><td>";
	           str1 += node1.selectSingleNode("./LinkMan").text+"&nbsp;";	
	           str1 += "</td></tr>";
              }

              if (null != node1.selectSingleNode("./Item_41_2") && node1.selectSingleNode("./Item_41_2").text != "null"&& node1.selectSingleNode("./Item_41_2").text != ""){
                  str1 += "<tr><td>【联系人电话】　</td><td>";
	          str1 += node1.selectSingleNode("./Item_41_2").text+"&nbsp;";		
	          str1 += "</td></tr>";
	       }

               if (null != node1.selectSingleNode("./Item_61") && node1.selectSingleNode("./Item_61").text != "null"&& node1.selectSingleNode("./Item_61").text != ""){
     	           str1 += "<tr><td>【联系人email】　</td><td>";
     	           str1 += node1.selectSingleNode("./Item_61").text+"&nbsp;";	
	           str1 += "</td></tr>";
	        }

               }
               if (null != node1.selectSingleNode("./UnitIntro") && node1.selectSingleNode("./UnitIntro").text != "null"&& node1.selectSingleNode("./UnitIntro").text != ""){
   	           str1 += "<tr><td colspan=\"2\">【单位简介】</td></tr>";
	           str1 += "<tr><td colspan=\"2\">　　";
	           str1 += node1.selectSingleNode("./UnitIntro").text+"&nbsp;";	
	           str1 += "</td></tr>";
	        }
            
               str1 += "</table>";
           
               if (document.all.showunitinfo !=null){
                         document.all.showunitinfo.innerHTML = str1;
	       }	
           else {
                         document.all.showunitinfo.style.display='none';  
           }
        }
        
          var str2 ="<div class=\"blank40\"></div>";
          str2 += "<div class=\"info_button\"><a href=\"javascript:window.print();\" ><img src=\"/SSTA/common/image/print.gif\" border=\"0\"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a  onclick=\"mycollect()\"><img src=\"/SSTA/common/image/collect.gif\"></a></div>";	
          if (document.all.collect !=null){
                document.all.collect.innerHTML = str2;
	      }*/																								                				

    }               
}



function getNewEnergyList(energyclass){
     if (energyclass=="7") 
         var url = path + "getNewEnergyList.jsp?keyword=ChannelShow='1'&energyclass='"+ energyclass +"'&num=8";
     else    
         var url = path + "getNewEnergyList.jsp?keyword=NewEnergyClass1='" + energyclass + "'  or NewEnergyClass2='" + energyclass + "'&energyclass='"+ energyclass +"'&num=8";
     XmlHttpPool.GetRemoteData(url, showNewEnergyList);	
    
}

function showNewEnergyList(data){ 
      var xml = new ActiveXObject("Microsoft.XMLDOM");
      xml.loadXML(data);
      resultDom.XMLDocument.loadXML(data);
      var tempobj = xml.documentElement;
      if(null != tempobj) {
	        var option = null;
                var nodelist = tempobj.selectNodes("//record");
                var searchresult = "";
                searchresult = "<div class=\"index_list\">";
	        searchresult += "<ul>"; 
                var len = nodelist.length;
                
                for(i = 0; i < len; i++) {
                      
                       searchresult += "<li>";
	               searchresult += "<a href = '/achieve/info.jsp?kjcgid=";
	               searchresult += nodelist.item(i).selectSingleNode(".//KjcgID").text;
                       searchresult += "&title="+nodelist.item(i).selectSingleNode(".//Kjcg_Item_3").text;
	               searchresult += "' target=\"_blank\"><img src=\"/achieve/image/point_blue.gif\" border=0/>&nbsp;&nbsp;";

                       if (trim(nodelist.item(i).selectSingleNode(".//Kjcg_Item_3").text).length > 18) 
                              searchresult += nodelist.item(i).selectSingleNode(".//Kjcg_Item_3").text.substring(0,17)+"...";
                       else 
                              searchresult += nodelist.item(i).selectSingleNode(".//Kjcg_Item_3").text;
                      
	              
	               searchresult += "</a>";
	               searchresult += "</li>";
                      
                }
                searchresult += "</ul>";
	        searchresult += "</div>"; 
                var energyclass="";
                if(xml.documentElement.selectSingleNode("//energyclass") != null) 
                  energyclass = xml.documentElement.selectSingleNode("//energyclass").text;
 
                 switch (energyclass) {     
                   case "\'1\'":
                      document.all["sun"].innerHTML = searchresult;  
                      break; 
                   case "\'2\'": 
                      document.all["wind"].innerHTML = searchresult;  
                      break;
                   case "\'3\'": 
                      document.all["living"].innerHTML = searchresult;  
                      break;
                   case "\'4\'": 
                      document.all["heat"].innerHTML = searchresult;  
                      break;
                   case "\'5\'": 
                      document.all["atom"].innerHTML = searchresult;  
                      break;
                   case "\'6\'": 
                      document.all["other"].innerHTML = searchresult;  
                      break;
                   case "\'7\'": 
                      document.all["recomm"].innerHTML = searchresult;  
                      break;
                 }
  } 
}


function changePage(no) {
        
        var url = path + "doSearch.jsp?keyword=" + searchkeyword;
        
	var rd = total - no * pagecap;
	if(rd > pagecap || no == 1) {
	    rd = pagecap;
	}
	else if(rd > 0 && rd < pagecap) {
	    rd = pagecap;
	}
	else {
	    rd = pagecap - (no * pagecap - total);
	}	    
	url += "&no="+ no + "&count="+pagecap;
    XmlHttpPool.GetRemoteData(url, showKjcgResult);     
}



